package com.baiduAI.body_seg;


import android.util.Log;

import com.baiduAI.body_seg.util.GsonUtils;
import com.baiduAI.body_seg.util.HttpUtil;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 图像修复
 */
public class Inpainting {


    public static String inpainting(String imageBase64, List<Object> rectangle) {
        // 请求url
        String url = "https://aip.baidubce.com/rest/2.0/image-process/v1/inpainting";
        try {
            Map<String, Object> map = new HashMap<>();
            map.put("image", imageBase64);
            map.put("rectangle", rectangle);

            String param = GsonUtils.toJson(map);

            // 注意这里仅为了简化编码每一次请求都去获取access_token，线上环境access_token有过期时间， 客户端可自行缓存，过期后重新获取。
            String accessToken = AuthService.getInpaintingAuth();
            Log.d("TAG", param);
            String result = HttpUtil.post(url, accessToken, "application/json", param);
            System.out.println(result);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

}